package entities;

public class CScrollingSprite extends CSprite 
{
	private float m_fScrollSpeedX = 1.0f;
	private float m_fScrollSpeedY = 1.0f;
	private float speed = 0.002f;
	public CScrollingSprite() 
	{
		
	}
	
	@Override 
	public void Update(float dt)
	{
		// scroll the uv's 
		mTextureBuffer.put(0, mTextureBuffer.get(0)-m_fScrollSpeedX*speed*dt);
		mTextureBuffer.put(2, mTextureBuffer.get(2)-m_fScrollSpeedX*speed*dt);
		mTextureBuffer.put(4, mTextureBuffer.get(4)-m_fScrollSpeedX*speed*dt);
		mTextureBuffer.put(6, mTextureBuffer.get(6)-m_fScrollSpeedX*speed*dt);

		mTextureBuffer.put(1, mTextureBuffer.get(1)+m_fScrollSpeedY*speed*dt);
		mTextureBuffer.put(3, mTextureBuffer.get(3)+m_fScrollSpeedY*speed*dt);
		mTextureBuffer.put(5, mTextureBuffer.get(5)+m_fScrollSpeedY*speed*dt);
		mTextureBuffer.put(7, mTextureBuffer.get(7)+m_fScrollSpeedY*speed*dt);
	}
	
	public void ScrollToX(float percent)
	{
		mTextureBuffer.put(0, percent);
		mTextureBuffer.put(2, percent);
		mTextureBuffer.put(4, percent);
		mTextureBuffer.put(6, percent);
	}
	
	// Accessors 
	public float getScrollDirX() { return m_fScrollSpeedX; }
	public float getScrollDirY() { return m_fScrollSpeedY; }
	public float getScrollSpeed() { return speed; }
	
	// Mutators
	public void setScrollDirX(float dir) { m_fScrollSpeedX = dir; }
	public void setScrollDirY(float dir) { m_fScrollSpeedY = dir; }
	public void setScrollSpeed(float s) { speed = s; }
}
